import request from '@/utils/request'

// 获取预处理数据点
export const beforeSpots = (fileName, frame = 5) => {
  return request({
    url: '/placement/before/spots',
    method: 'get',
    params: {
      file_name: fileName,
      frame: frame
    }
  })
}
// 开始计算
export const startCalculation = (params) => {
  return request({
    url: '/placement/calculate',
    method: 'post',
    data: params
  })
}
// 可视化计算
export const visualizeCalculation = (params) => {
  return request({
    url: '/placement/visual',
    method: 'post',
    data: params
  })
}
// 解析散点数据
export const parseSpots = (taskId) => {
  return request({
    url: '/placement/after/spots',
    method: 'get',
    params: {
      task_id: taskId
    }
  })
}
// 解析3D概率密度数据
export const parse3DProbabilityDensity = (taskId, fileName, frame) => {
  return request({
    url: '/placement/3d',
    method: 'get',
    params: {
      task_id: taskId,
      file_name: fileName,
      frame: frame
    }
  })
}
// 下载结算结果（可选传入 frame 参数）
export const downloadResults = (frame) => {
  return request({
    url: '/placement/download_result',
    method: 'get',
    params: typeof frame === 'number' ? { frame } : undefined,
    responseType: 'blob' // 下载二进制文件
  })
}